<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="admin/public/layout">

<head>
    <title>时间设置</title>
</head>
<div  layout:fragment="content">
    <section class="content-header">
        <h1>
            时间设置
            <small>默认时区及时间格式设置</small>
        </h1>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <form  th:object="${settingTime}" role="form" name="addForm" method="POST" th:action="@{/admin/setting/time}">
                        <input type="hidden" name="id" th:value="${GlobalSetting.time.id}">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="time_offset">默认时区</label>
                                <select name="offset" class="form-control">
                                    <option th:each="offset:${GlobalTimeOffset}" th:value="${offset.value}" th:selected="${offset.value == settingTime.offset+''}" th:text="${offset.name}"></option>

                                </select>
                            </div>

                            <div th:class="${#fields.hasErrors('diff')}?'form-group has-error':'form-group'">
                                <label>本地时间与服务器的时间差</label>
                                <span class="text-muted">(时间差(分钟)，例如本地 8:00 服务器 8:10，则填写-10)</span>
                                <input type="text" name="diff" class="form-control " placeholder="" th:value="${settingTime.diff}">
                                <p class="help-block" th:if="${#fields.hasErrors('diff')}" th:text="${#fields.errors('diff')[0]}"></p>
                            </div>

                            <div class="form-group">
                                <label>日期格式</label>
                                <select name="dateFormat" class="form-control">
                                    <option value="Y/m/d"  th:selected="${settingTime.dateFormat == 'Y/m/d'}"  th:text="${#dates.format(currentTime,'Y/m/d')}+'（Y/m/d）'" >   </option>
                                    <option value="m/d/Y"  th:selected="${settingTime.dateFormat == 'm/d/Y'}"  th:text="${#dates.format(currentTime,'m/d/Y')}+'（m/d/Y）'" > </option>
                                    <option value="d/m/Y"  th:selected="${settingTime.dateFormat == 'd/m/Y'}"  th:text="${#dates.format(currentTime,'d/m/Y')}+'（d/m/Y）'" >   </option>
                                    <option value="Y.m.d"  th:selected="${settingTime.dateFormat == 'Y.m.d'}"  th:text="${#dates.format(currentTime,'Y.m.d')}+'（Y.m.d）'" > </option>
                                    <option value="m.d.Y"  th:selected="${settingTime.dateFormat == 'm.d.Y'}"  th:text="${#dates.format(currentTime,'m.d.Y')}+'（m.d.Y）'" >   </option>
                                    <option value="Y-m-d"  th:selected="${settingTime.dateFormat == 'Y-m-d'}"  th:text="${#dates.format(currentTime,'Y-m-d')}+'（Y-m-d）'" > </option>
                                    <option value="m-d-Y"  th:selected="${settingTime.dateFormat == 'm-d-Y'}"  th:text="${#dates.format(currentTime,'m-d-Y')}+'（m-d-Y）'" >   </option>
                                    <option value="d-m-Y"  th:selected="${settingTime.dateFormat == 'd-m-Y'}"  th:text="${#dates.format(currentTime,'d-m-Y')}+'（m-d-Y）'" > </option>
                                </select>
                            </div>

                            <div class="form-group">
                                <label>时间格式</label>
                                <select name="timeFormat" class="form-control">
                                    <option value="H:m"   th:selected="${settingTime.timeFormat == 'H:m'}" th:text="${#dates.format(currentTime,'H:m')}+'（H:m）'"></option>
                                    <option value="H:m:s"  th:selected="${settingTime.timeFormat == 'H:m:s'}" th:text="${#dates.format(currentTime,'H:m:s')}+'（H:m:s）'"></option>
                                </select>
                            </div>

                            <div th:class="${#fields.hasErrors('friendly')}?'form-group has-error':'form-group'">
                                <label>人性化时间格式</label>
                                <span class="text-muted">(开启之后，系统中的时间将显示以“n分钟前”、“昨天”、“n天前”等形式显示)</span>
                                <div class="radio">
                                    <label><input type="radio" name="time_friendly"  value="true" th:checked="${settingTime.friendly}">是</label>&nbsp;&nbsp;&nbsp;&nbsp;
                                    <label><input type="radio" name="time_friendly"  value="false" th:checked="!${settingTime.friendly}">否</label>
                                </div>
                            </div>


                        </div>
                        <div class="box-footer">
                            <button type="submit" class="btn btn-primary">保存</button>
                            <button type="reset" class="btn btn-success">重置</button>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </section>
</div>